/*
package com.cyy.user.service;


import com.cyy.user.dao.UserDao;
import com.cyy.user.pojo.User;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import util.IdWorker;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
import java.util.concurrent.TimeUnit;

*/
/**
 * user服务层
 *
 * @author Administrator
 *
 *//*


@Service
public class UserService {

	@Autowired
	public RedisTemplate redisTemplate;

	@Autowired
	private RabbitTemplate rabbitTemplate;

	@Autowired
	private IdWorker idWorker;

	@Autowired
	private UserDao userDao;

	*/
/**
	 * 发送短信
	 * @param moblie
	 *//*

	public void sendSms(String moblie){

		//生成六位数随机数
		Random random = new Random();
		int max = 999999;
		int min = 100000;
		int code = random.nextInt(max);
		if(code < min){
			code = code + min;
		}
		System.out.println("收到的验证码是：" + code);
		//将验证码设置到redis里面
		redisTemplate.opsForValue().set("smscode_"+moblie,code+"",5, TimeUnit.MINUTES);//5分钟后过期

		Map<String,Object> map = new HashMap<>();
		map.put("mobile",moblie);
		map.put("code",code);

		//发送短信
		rabbitTemplate.convertAndSend("sms",map);
	}

	*/
/**
	 * 注册用户
	 * @param user
	 * @param code
	 *//*

	public void add(User user, String code) {
		String sysCode = (String) redisTemplate.opsForValue().get("smscode_"+user.getMobile());
		if(sysCode == null){
			throw new  RuntimeException("请点击获取验证码！");
		}
		if(!code.equals(sysCode)){
			throw new RuntimeException("验证码不正确！");
		}
		user.setBirthday(new Date("1995/08/26"));
		user.setEmail("1773247011@qq.com");
		user.setFanscount(0);//粉丝数
		user.setFollowcount(0);//关注数
		user.setId(idWorker.nextId() + "");
		user.setLastdate(new Date());
		user.setOnline(0L);
		user.setRegdate(new Date());//注册日期
		user.setUpdatedate(new Date());//更新日期

		userDao.save(user);
	}
}
*/
